docs: document conditional execution via QUARTO_EXECUTE_INFO#2043
docs: document conditional execution via QUARTO_EXECUTE_INFO#2043cderv wants to merge 10 commits into
Conversation
Adds a section linking to docs/advanced/quarto-execute-info.qmd so users browsing execution options discover the format-aware QUARTO_EXECUTE_INFO env var. Part of #13514.
Points readers of computations/r.qmd at QUARTO_EXECUTE_INFO so they can branch on output format. Mirrors the additions for Python and Julia. Part of #13514.
The {r} marker was unescaped inside a markdown verbatim block;
Quarto would have treated it as an executable cell on render.
Matches the {{r}} escape pattern used by the sibling Chunk Labels
example in the same file.
Part of #13514.
Points readers of computations/python.qmd at QUARTO_EXECUTE_INFO so they can branch on output format. Mirrors the additions for R and Julia. Part of #13514.
Points readers of computations/julia.qmd at QUARTO_EXECUTE_INFO so they can branch on output format. Mirrors the additions for R and Python. Part of #13514.
Markup-based .content-visible / .content-hidden hide output but do not skip execution. Adds a pointer section to QUARTO_EXECUTE_INFO for the execution-level case. Part of #13514.
Pre-existing EOF lacked a terminal newline; appending Conditional Execution section preserved that. Aligns with other .qmd files in the repo. Part of #13514.
The conditional-content example in cross-references-divs.qmd hides one branch but still runs both. Adds two pointers: (1) QUARTO_EXECUTE_INFO for users who need to skip execution, (2) project profiles as another axis for content variation beyond output format. Both flagged in issue thread. Part of #13514.
conditional.qmd and cross-references-divs.qmd both clarify that .content-visible / .content-hidden hide output but do not skip execution. The two paragraphs duplicated the same takeaway in slightly different words. Extract the single canonical version to docs/authoring/_visibility-vs-execution.md and include it from both pages. The project-profiles paragraph in cross-references-divs.qmd stays inline (specific to that page). Part of #13514.
R cells run through knitr by default, which has long offered is_html_output(), is_latex_output(), and pandoc_to() for the common format-detection cases. Worth pointing readers at those alongside the engine-agnostic QUARTO_EXECUTE_INFO approach (flagged in the issue thread by cderv). Part of #13514.
📝 Preview Deployment🔍 Full site preview: https://deploy-preview-2043.quarto.org 🔄 Modified Documents |
cwickham
left a comment
There was a problem hiding this comment.
Edits look great!
Is this comment in the PR from Claude?:
The added language snippets contain no executable code (wrapped in verbatim markdown fences with {{lang}} escaped cell markers), so no _freeze/ updates are introduced.
The reasoning seems wrong, i.e. even if includes don't introduce executable code, we still need to update _freeze/ if the original page has executable code. Might be worth a rule/instruction somewhere for Claude...
In this case docs/computations/execution-options.qmd has executable code and does need a re-render, commit to _freeze/.
| [QuartoNotebookRunner](https://github.com/PumasAI/QuartoNotebookRunner.jl) | ||
| repository. | ||
|
|
||
| ## Conditional Execution |
There was a problem hiding this comment.
This ends up nested under "Using the julia engine" but it applies to both engines. Either repeat it, or move it up a level.
|
|
||
| ## Conditional Execution | ||
|
|
||
| To execute a cell only for certain output formats, read the [`QUARTO_EXECUTE_INFO`](/docs/advanced/quarto-execute-info.qmd) environment variable inside the cell: |
There was a problem hiding this comment.
This applies to all the docs/computations/<language>.qmd files: I think we can add a bit more explanation of what the code does.
E.g.
| To execute a cell only for certain output formats, read the [`QUARTO_EXECUTE_INFO`](/docs/advanced/quarto-execute-info.qmd) environment variable inside the cell: | |
| To execute a cell only for certain output formats, read the [`QUARTO_EXECUTE_INFO`](/docs/advanced/quarto-execute-info.qmd) environment variable inside the cell. | |
| For example, you could execute code only if the target format is based on HTML (e.g. for `html`, `revealjs`, and `dashboard` formats): |
|
|
||
| {{< include _visibility-vs-execution.md >}} | ||
|
|
||
| When the variation you need is broader than output format — for example, the same document rendered as a draft vs. a final, or for an internal vs. an external audience — [project profiles](/docs/projects/profiles.qmd) can set alternate metadata per profile that `.content-visible when-meta=...` reads. This gives you another axis for conditional content beyond `when-format`. |
There was a problem hiding this comment.
| When the variation you need is broader than output format — for example, the same document rendered as a draft vs. a final, or for an internal vs. an external audience — [project profiles](/docs/projects/profiles.qmd) can set alternate metadata per profile that `.content-visible when-meta=...` reads. This gives you another axis for conditional content beyond `when-format`. | |
| When you want visibility to depend on something beyond output format — for example, the same document rendered as a draft vs. a final version, or for an internal vs. an external audience — combine `.content-visible`/`.content-hidden` with the `when-meta` attribute. | |
| You can then control visibility with values you set in your metadata, either in your document header, or via [project profiles](/docs/projects/profiles.qmd). |
| ```` | ||
|
|
||
| Note that the Knitr engine also supports ```` ```{python} ```` cells, enabling the combination of R, Python, and Bash in the same document | ||
|
|
There was a problem hiding this comment.
I'm not seeing this edit...needs _freeze I think.
Cross-link the existing
QUARTO_EXECUTE_INFOreference page (docs/advanced/quarto-execute-info.qmd) from the six pages users actually browse when looking for conditional-execution behavior. The reference page itself is not modified.Per the issue thread on quarto-dev/quarto-cli#13514, users want both:
docs/advanced/quarto-execute-info.qmd, already exists)This branch addresses the second part — the first already exists.
Changes
docs/computations/execution-options.qmd— new## Conditional Executionsection explaining the distinction from format-based conditional content.docs/computations/r.qmd,python.qmd,julia.qmd—## Conditional Executionsection per language, with a short verbatim snippet showing how to readQUARTO_EXECUTE_INFO. The R section also points atknitr::is_html_output(),knitr::is_latex_output(), andknitr::pandoc_to()for users who only need the common cases.docs/authoring/conditional.qmd— explicit clarifier that.content-visible/.content-hiddenhide output but do not skip execution (per cwickham's ask in the thread).docs/authoring/cross-references-divs.qmd— same execution clarifier, plus a note pointing at project profiles as another axis for content variation beyondwhen-format.docs/authoring/_visibility-vs-execution.md— shared partial used by both authoring pages so the execution-vs-visibility note has a single source of truth.The added language snippets contain no executable code (wrapped in verbatim markdown fences with
{{lang}}escaped cell markers), so no_freeze/updates are introduced.Test Plan
cross-references-divs.qmdConditional Content section now ends with the two notes (execution + project profiles) plus the existing example._visibility-vs-execution.mdpartial renders identically in both consumer pages._freeze/regeneration triggered.Closes quarto-dev/quarto-cli#13514